
/* 
 * Since 2008 - 2012
 */
package com.hh.bss.sysadmin.controller;

import static com.hh.bss.util.extjs.JsonHelper.outJson;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.filters.MappingPropertyFilter;
import net.sf.json.util.PropertyFilter;

import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;


import com.hh.bss.base.*;
import com.hh.bss.common.ConstantDic;
import com.hh.bss.common.cache.SystemDicCache;
import com.hh.bss.common.page.*;
import com.hh.bss.common.page.impl.*;
import com.hh.bss.sysadmin.dao.*;
import com.hh.bss.sysadmin.entity.*;
import com.hh.bss.sysadmin.service.*;
import com.hh.bss.sysadmin.vo.query.*;
import com.hh.bss.util.*;
import com.hh.bss.util.extjs.ExtJsPageHelper;
import com.hh.bss.util.extjs.JsonHelper;
import com.hh.bss.util.extjs.ListRange;

import java.util.*;





@Controller
public class SystemConstantDicController extends BaseSpringController{
	
	public void list(HttpServletRequest request,HttpServletResponse response,String category) throws IOException
	{
		try{
		
		Object categorys=null;
		boolean isVar=false;
		if (!StringHelper.isEmpty(request.getParameter("isvar"))){
			 isVar=true;
		}
		
		if (StringHelper.isEmpty(category)){
			
		   categorys=ConstantDic.getAllConstantDicCategory();//SystemDicCache.getSystemDicCategoryListMap();
		}
		else {
			categorys=ConstantDic.getConstantDicCategory(category);//SystemDicCache.getCategoryList(systemDicQuery.getCategory());
			
		}		
        
		//System.out.println(JSONObject.fromObject(m,jsonConfig).toString());
		StringBuffer sb=new StringBuffer();

		String jsonStr="";
		
		if (isVar)
		   jsonStr=JSONObject.fromObject(categorys).toString();
		else jsonStr=JSONArray.fromObject(categorys).toString();

		if (isVar)sb.append("var allConstantDic=").append(jsonStr).append(";");
		else sb.append(jsonStr);
		JsonHelper.outJsonString(response,sb.toString());
		//systemDicCache.setSystemDicDaoImpl(systemDicService.g);
		}catch(Exception ex){
			ex.printStackTrace();
			//throw ex;
		}
	}

	
}
